import numpy as np
from aStar import aStar
from utils import crd_game_to_gird, crd_grid_to_game, one_zero_map

def calcEnemy(stat):
  player=[p.copy() for p in stat['playerStateVos'] if p['playerId']==stat['playerId']][0]
  player['x'],player['y']=player['y'],player['x']
  speed10=player['speed']==10
  map=np.array(stat['map'])
  pass_map=one_zero_map(map)
  dir={
    1:(-1,0),
    2:(1,0),
    3:(0,-1),
    4:(0,1)
  }
  
  x,y=crd_game_to_gird((player['x'],player['y']))
  
  max_enemy=sorted([p.copy() for p in stat['playerStateVos'] if p['teamColor']!=player['teamColor']],key=lambda x:x['rank'])[0]
  max_enemy['x'],max_enemy['y']=max_enemy['y'],max_enemy['x']
  ex,ey=crd_game_to_gird((max_enemy['x'], max_enemy['y']))
  return (max_enemy['x'],max_enemy['y'],max_enemy['playerId']),aStar(map,(x,y),(ex,ey),speed10)
  
  
  
  

  
  